import loginApi from '@/common/api/login';
import nativeAction from '@/common/native';
import util from '@/common/util';
import api from '@/common/api/api';
import constant from '@/common/constant';
/**
 * 登录请求服务器接口
 * @module login/login
 * @author dym
 */
export default {
  /**
   * @example 参数
   * @returns {Object} 登录接口
   */
  login (submitobj, that) {
    loginApi.login(submitobj).then(res => {
      constant.phoneInfo.username = submitobj.username;
      if (constant.phoneInfo.regId) {
        api.setPhoneType(constant.phoneInfo);
      }
      //设置登录信息
      if (res.user.bizCounts === 1) {
        util.loginTask(res);
      } else if (res.user.bizCounts > 1) {
        nativeAction.setInfo(res.user);
        that.$router.push('/selectCompany');
      } else {
        nativeAction.setInfo(res.user);
        that.$router.push('/bindingShop');
      }
    });
  },
  windowHeight: 0
};
